package com.hnkywl.jip.interceptor;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.StrutsStatics;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2010-6-7
 * Time: 10:52:59
 * To change this template use File | Settings | File Templates.
 */
public class AuthInterceptor extends AbstractInterceptor {
    public static final String SESSION_KEY = "SESSION_KEY";
    public static final String USER_ID_SESSION_KEY = "USER_ID_SESSION_KEY";
    public static final String USER_NAME_SESSION_KEY = "USER_NAME_SESSION_KEY";
    public static final String USER_PASSWORD_SESSION_KEY = "USER_PASSWORD_SESSION_KEY";
    public static final String JIP_USERNAME_SESSION_KEY = "JIP_USERNAME_SESSION_KEY";
    public static final String JIP_PASSWORD_SESSION_KEY = "JIP_PASSWORD_SESSION_KEY";


    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        ActionContext actionContext = invocation.getInvocationContext();
        Map session = actionContext.getSession();
        if (session != null && session.get(SESSION_KEY) != null) {
            return invocation.invoke();
        }
        return "login";
    }


}